﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MovieCollectionManager.DataModel;

namespace MovieCollectionManager
{
    public partial class PendingLoansForm : Form
    {
        public PendingLoansForm()
        {
            InitializeComponent();
        }

        private void PendingLoansForm_Load(object sender, EventArgs e)
        {
            List<string> pendingUsers = new List<string>();
            using (var db = new MovieCollectionConteiner())
            {
                foreach (Loan loan in db.Loans)
                {
                    if ((loan.ReturnDate.CompareTo(DateTime.Now) == -1) && (!pendingUsers.Contains(loan.Receiver)))
                    {
                        pendingUsers.Add(loan.Receiver);
                    }
                }
            }

            listBoxUsersInDebt.DataSource = pendingUsers;
        }

        private void buttonOk_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
